Input Devices
On this page, I will be showing on how I used TinkerCAD to do up a circuit using an input device called the potentiometer.
Input Devices
Step 1
The first step is to do up the circuit below in TinkerCAD.
Step 2
The second step is to do up the coding part of the circuit. Below is the code I copied and modified from https://www.arduino.cc/en/tutorial/potentiometer. It delays 1 second + the output from potentiometer.
int potPin = 4; // select the input pin for the potentiometer int ledPin = 11; // select the pin for the LED int val = 0; // variable to store the value coming from the sensor void setup() { pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT } void loop() { val = analogRead(potPin); // read the value from the sensor digitalWrite(ledPin, HIGH); // turn the ledPin on delay(val+1000); // stop the program for some time digitalWrite(ledPin, LOW); // turn the ledPin off delay(val+1000); // stop the program for some time }
Done!
This step is here to make sure the code works and do check if there are any errors.